fh = open('a.xml','wb')
name = ""
x = '0'
y = '0'
w = '0'
h = '0'
suffix = ''
with open('sprites.txt','r') as f:
    for line in f:
        
        if 'rotate' in line:
            print line
        elif 'xy' in line:
            xy= line.strip(' \t\n\r').replace(' ','').split(':')[1].split(',')
            x= xy[0]
            y= xy[1]
        elif 'size' in line:
            xy= line.strip(' \t\n\r').replace(' ','').split(':')[1].split(',')
            w= xy[0]
            h= xy[1]
        elif 'orig' in line:
            print line
        elif 'offset' in line:
            print line
        elif 'index' in line:
            if '-1' in line:
                pass
            else:
                suffix='_'+line.strip(' \t\n\r').replace(' ','').replace('index','').replace(':','')
            fh.write('<SubTexture name="'+name+suffix+'" x="'+x+'" y="'+y+'" width="'+w+'" height="'+h+'"/>\n')
            name = ""
            x = '0'
            y = '0'
            w = '0'
            h = '0'
            suffix = ''
        else:
            name = line.strip(' \t\n\r')
            





fh.close()
